<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑页面</title>
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript" src="/staticimg/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript">
        function out(){
            location.href="/getAllUsers";
        }

        function foom(){
            alert("编辑成功!正在进入展示页面。。。");
        }

        // 当元素的值发生改变时，会发生 change 事件。
        $(function () {
            $("#deptidid").change(function () {
                //1、获取被选中的value
                var did=$(this).val();
                if(did==-1){
                    alert("请选择部门");
                }else {
                    $.ajax({
                        url:"/getroles",
                        data:"did="+did,
                        type:"post",
                        dataType:"json",
                        success:function (rs) {    //rs用来接收返回的结果
                            ///让下拉框的长度为0，也就是rs的长度为0
                            $("#role")[0].length=0;
                            for(var i=0;i<rs.length;i++){
                                //此处是定位到这个add.jsp页面里的角色对象（var role= $("#role");），之后点出add方法，
                                //此处的[0]是因为add方法为js的方法，所以得把得到的jquery对象化为js对象，加个[0]就OK
                                // 为下拉框添加元素
                                //Option(显示到标签对中的值，value值)
                                $("#role")[0].add(new Option(rs[i].uname,rs[i].uid));

                            }
                        }
                    })
                }
            })
        })

    </script>
</head>
<body>

<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <h3 class="text-center text-success">
                编辑页面
            </h3>
            <form role="form" action="/updateperson" method="post">
                <input type="hidden" class="form-control" name="pid" value="${users.pid}"/>
                <div class="form-group">
                    <label for="exampleInputEmail1">员工账号</label><input type="text" class="form-control" name="pzhanghao" value="${users.pzhanghao}" required/>
                </div>
                <h5 id="zhanghao1"></h5>
                <div class="form-group">
                    <label for="exampleInputPassword1">员工姓名</label><input type="text" class="form-control" name="pname" value="${users.pname}" required/>
                </div>
                <h5 id="name1"></h5>
                <#--                        -->
                <div class="form-group">
                    <label for="exampleInputEmail1" >所属部门</label>
                    <select class="span6 m-wrap" name="pdept" id="deptidid" style="width:178px;" >
                        <option value="-1" >--选择分类--</option>
                        <#list depts as student>
                            <option value="${student.did}" <#if student.did==users.pid>selected="selected"</#if>>${student.dname}</option>
                        </#list>
                    </select>
                </div>

                <div class="form-group">
                    <label for="exampleInputEmail1">选择职位</label>
                    <select class="span6 m-wrap" name="uid" id="role" style="width:178px;" >
                        <option value="${users.uid}">${user.uname}</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="exampleInputPassword1">性别</label><input type="text" class="form-control" name="sex" value="${users.sex}" required/>
                </div>
                <div class="form-group">
                    <label for="exampleInputPassword1">身份证号</label><input type="text" class="form-control" name="cardid" value="${users.cardid}" required/>
                </div>
                <h5 id="card1"></h5>
                <div class="form-group">
                    <label for="exampleInputPassword1">手机号</label><input type="text" class="form-control" name="pnumber" value="${users.pnumber}" required/>
                </div>
                <div class="form-group">
                    <label for="exampleInputPassword1">QQ</label><input type="text" class="form-control" name="qq" value="${users.qq}" required/>
                </div>
                <div class="form-group">
                    <label for="exampleInputPassword1">破壳日</label><input type="date" class="form-control" name="birthday" value="${users.birthday?string('yyyy-MM-dd')}" required/>
                </div>
                <div class="form-group">
                    <label for="exampleInputPassword1">登陆密码</label><input type="text" class="form-control" name="ppassword" value="${users.ppassword}" required/>
                </div>
                <h5 id="pw"></h5>
                <div class="form-group">
                    <label for="exampleInputPassword1">确认密码</label><input type="text" class="form-control" name="ppassword1" value="${users.ppassword}" required/>
                </div>
                <h5 id="pw1"></h5>
                <button type="submit" class="btn btn-default" onclick="foom()" id="sub_btn">提交</button>
                <button type="submit" class="btn btn-default" onclick="out()">返回</button>

            </form>
        </div>
    </div>
</div>


</body>
</html>